package com.lee.common.exception;

import lombok.Getter;

import static com.lee.common.exception.FailureStatus.*;

/**
 * @author Lee HN
 * @date 2024/4/13 17:55
 */
@Getter
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 2277040100368288735L;

    public static final CustomException NO_AUTHENTICATED_EXC = new CustomException(NO_AUTHENTICATED);

    public static final CustomException INVALID_CREDENTIAL_EXC = new CustomException(INVALID_CREDENTIAL);

    public static final CustomException EXPIRED_CREDENTIAL_EXC = new CustomException(EXPIRED_CREDENTIAL);

    public static final CustomException AUTHORITY_DENIED_EXC = new CustomException(AUTHORITY_DENIED);

    public static final CustomException BAD_CREDENTIAL_EXC = new CustomException(BAD_CREDENTIAL);

    public static final CustomException BAD_OPERATION_EXC = new CustomException(BAD_OPERATION);

    public static final CustomException BAD_STATUS_EXC = new CustomException(BAD_STATUS);

    public static final CustomException NO_DATA_EXC = new CustomException(NO_DATA);

    public static final CustomException BAD_PARAM_EXC = new CustomException(BAD_PARAM);

    public static final CustomException NONENTITY_USER_EXC = new CustomException(NONENTITY_USER);

    public static final CustomException SERVER_ERROR_EXC = new CustomException(SERVER_ERROR);

    private final FailureStatus status;

    public CustomException(FailureStatus status, String message) {
        super(message, null, false, false);
        this.status = status;
    }

    private CustomException(FailureStatus status) {
        super(status.getMessage(), null, false, false);
        this.status = status;
    }

}
